/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * Ref: ECS lab
 */
package recycle;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 *
 * @author kkkkkkkkkkkk
 */
public class Delegator extends HttpServlet{
    
    //This method is automatically called when the servlet 
    //engine receives an HTTP GET request for this servlet.
    public void goGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        doPost(request, response);
    }
    
    //This method is automatically called when the servlet 
    //engine receives an HTTP POST request for this servlet.
    public void goPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        processRequest(request, response);
    }
    
    //Called by doGet() and doPost()effectively
    public void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        //Gets hold of the outputstream which can be used to
        //send data back to the browser (or whoever called 
        // the servlet).
        ServletContext context = getServletContext();
        RequestDispatcher rd = context.getRequestDispatcher("/autodiary/FileUpload.class");

        //PrintWriter printWriter = new PrintWriter( new OutputStreamWriter(response.getOutputStream()), true);
        
        //Tells the browser that we are sending data in HTML format
        //response.setContentType("text/html");
  
        
        // Send a small HTML document back
        //printWriter.println("<HTML><BODY>This is delegator servlet</BODY></HTML>");
        

    }

}
